<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>网站标题</title>
<meta name="keywords" content="关键词,关键词,关键词,关键词,5个关键词" />
<meta name="description" content="网站简介，不超过80个字" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../lib/layui/css/layui.css">
<link href="../front/css/index.css" rel="stylesheet">
<script src="../front/js/jquery.min.js"></script>
<script src="../front/js/comm.js"></script>
<!--[if lt IE 9]>
 <script src="js/modernizr.js"></script>
 <![endif]-->
</head>
<body>
	<header>
		<div class="logo">杨青个人博客</div>
		<div class="top-nav">
			<h2 id="mnavh">
				<span class="navicon"></span>
			</h2>
			<ul id="nav">
				<li ><a href="../index"> 网站首页</a></li>
				<c:if test="${fenlei!=null}">
					<c:forEach items="${fenlei}" var="tion">
						<li><a href="../main?cid=${tion.cid}">${tion.cName}</a></li>
					</c:forEach>
				</c:if>
				<li><a href="../Aboutme">关于我</a></li>
				<li><a href="../Leaves">留言</a></li>
					<c:if test="${userz!=null}">
						<li><a href="../indexs">${userz.userName}</a></li>
						<li><a href="../tuichu">退出</a>
				</c:if>
				<c:if test="${userz==null}">
					<li><a href="../login.html">登录</a></li>
				</c:if>	
			</ul>
		</div>
	</header>
	<aside class="side">
		<div class="about">
			<i><a href="/"><img src="../front/images/avatar.jpg"></a></i>
			<p>杨青，一个80后草根女站长！09年入行。一直潜心研究web前端技术，一边工作一边积累经验，分享一些个人博客模板，以及SEO优化等心得。</p>
		</div>
		<div class="weixin">
			<img src="../front/images/wx.jpg">
			<p>关注我 么么哒！</p>
		</div>
	</aside>
	<main>
	<div class="main-content">

		<div class="welcome">
			您现在的位置是：<a href="../index">首页 </a> > <a
				href="../main?cid=${content.classification.cid}">${content.classification.cName}</a>
		</div>
		<div class="blogbox">
			<c:if test="${content!=null}">
				<input type="hidden" class="${content.classification.cid}" id="cid">
				<input type="hidden" class="${content.tid}" id="tid">
				<div class="contentbox">
					<h2 class="contitle">${content.tcontentheader}</h2>
					<p class="bloginfo">
						<span>${content.author}</span><span> <fmt:formatDate
								value="${content.tcreationtime}" pattern="yyyy-MM-dd" />
						</span><span><a href="main?cid=${content.classification.cid}">${content.classification.cName}</a></span>
					</p>
					<div id="contentxzs" style="display: none;">
						${content.tcontent}</div>
					<span id="shenmoyaomi"></span>
					<div class="share"></div>
					<div class="nextinfo"></div>
				</div>
			</c:if>
			<div class="pinlun">
				<h2 class="newstitle">
					<b>评论(温馨提醒如果没登陆添加评论时会留下您的ip)</b>
				</h2>
				<div id="addcomments" style="margin-top: 5px; margin-left: 10px;">
					<form class="layui-form">
						<input type="hidden" name="content.tid" value="${content.tid}">
						<textarea rows="5" cols="100" name="lcontent" style="width: 750px;margin-left:10px; margin-top: 20px;"></textarea>
						<button class="layui-btn layui-btn-primary" lay-filter="layuiBtn"
							lay-submit style="margin-left: 20px;margin-bottom: 50px;">添加评论</button>
					</form>
				</div>
				<div class="gbok">
					<c:if test="${comments!=null and comments.totalPages!=0}">
						<div class="zongcomment"></div>
						<c:forEach items="${comments.data}" var="comment">
							<div class="commentz"
								style="border: 1px solid #ccc; height: 100px;margin-bottom: 10px;padding-top: 10px;padding-left: 10px;padding-right: 10px;"">
								评论人:<span class="ip">${comment.iPaddress}</span> <span
									class="shijian" style="margin-left: 600px"><fmt:formatDate
										value="${comment.lmessagetime}" pattern="yyyy-MM-dd" /></span> <br />
								<br /> <span class="neirong">${comment.lcontent}</span>
							</div>
						</c:forEach>
			<div style="padding-left: 300px;padding-top: 50px;">
				总页数:${comments.totalPages}
				<a href="javascript:" onclick="fenye(page-1)"style="padding-left: 30px;">上一页</a>
						<c:forEach end="${comments.totalPages}" begin="1" var="no">
							<a href="javascript:" onclick="fenye(${no})"style="padding-left: 30px;">${no}</a>
						</c:forEach>
						<a href="javascript:" onclick="fenye(page+1)"style="padding-left: 30px;">下一页</a>
					</div>
					</c:if>
				</div>
			</div>

		</div>
		<div class="rside">
			<div class="news">
				<h2 class="newstitle">
					<b>文章排行</b>
				</h2>
				<ul>
					<c:if test="${neirong1!=null}">
						<c:forEach items="${neirong1}" var="tion">
							<li><a href="${tion.tid}"><span><fmt:formatDate
											value="${tion.tcreationtime}" pattern="MM-dd" /></span>${tion.tcontentheader}</a></li>
						</c:forEach>
					</c:if>
				</ul>
			</div>
			<div class="news">
				<h2 class="newstitle">
					<b>本栏推荐</b>
				</h2>
				<ul>
					<c:if test="${neirong2!=null}">
						<c:forEach items="${neirong2}" var="tion">
							<li><a href="${tion.tid}"><span> <fmt:formatDate
											value="${tion.tcreationtime}" pattern="MM-dd" /></span>
									${tion.tcontentheader}</a></li>
						</c:forEach>
					</c:if>
				</ul>
			</div>
		</div>
	</div>
	<div class="copyright">
		<p>
			Copyright 2018 Inc. AllRights Reserved. Design by <a href="/">杨青个人博客</a>
			蜀ICP备11002373号-1
		</p>
	</div>
	</div>
	</main>
	<a href="#" class="cd-top cd-is-visible">Top</a>
</body>
<script src="../lib/layui/layui.js"></script>
<script type="text/javascript">


 var page=1;//当前页
 var limit=10;//每页显示数
 var content=$("#contentxzs").text();
 $("#shenmoyaomi").html(content);
 var tid=$("#tid").attr("class");
 layui.use('form',function(){
	 var form = layui.form;
 form.on('submit(layuiBtn)', function(data){
  $.post("../addcomment",data.field,function(datas){
	  if(datas==true){
		  alert("添加成功！");
		  location.href = ""+tid+"";
	  }else{
		  alert("玩不下去了勒");
	  }
  }),"json";
  return false; 
 })
 })
 //后台返回一串String类型的数值转成Date类型的方法
 Date.prototype.Format = function(fmt)   
{ 
//author:wangweizhen
  var o = {   
    "M+" : this.getMonth()+1,                 //月份   
    "d+" : this.getDate(),                    //日
    "h+" : this.getHours(),                   //小时   
    "m+" : this.getMinutes(),                 //分   
    "s+" : this.getSeconds(),                 //秒   
    "q+" : Math.floor((this.getMonth()+3)/3), //季度   
    "S"  : this.getMilliseconds()             //毫秒   
  };   
  if(/(y+)/.test(fmt))   
    fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
  for(var k in o)   
    if(new RegExp("("+ k +")").test(fmt))   
  fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));   
  return fmt;   
};
 
 //当用户点击上一页或下一页页或任意数字
 function fenye(p) {
	var tid= $("#tid").attr("class");
	if(p>=1){
		page=p;
		$.ajax({
			type:"post",//请求方式
			url:"../infofenye/"+tid+"?page="+page,//请求路径
			dataType:"json",//返回json数据
			 success:function(data){
				$(".commentz").remove();
				for (var i = 0; i < data.data.length; i++) {
					 var date = new Date(data.data[i].lmessagetime);
					 date.Format("yyyy-MM-dd hh:mm:ss");
					var comment=" <div class='commentz' style='border: 1px solid #ccc; height: 100px;'>"+ 
					" 评论ip:<span class='ip'>"+ data.data[i].iPaddress +" </span>"+ 
					" <span class='shijian'style='margin-left: 600px'> "+
					""+date.Format("yyyy-MM-dd")+"</span>"+
					" <br/><br/><span class='neirong'>"+ data.data[i].lcontent +" </span></div>"
					$(".zongcomment").append(comment);
				}
			}
		});
	}
}
 </script>
</html>